<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<rapid:override name="frame-header-style">
    <style>
        /*覆盖 layui*/
        .layui-input-block {
            margin: 0px 10px;
        }

        .layui-table {
            margin-top: 0;
        }

        .layui-col-md4 {
            padding: 10px;
        }

        .layui-col-md8 {
            padding: 10px;
        }

        .layui-btn {
            margin: 2px 0 !important;
        }
    </style>
</rapid:override>

<rapid:override name="frame-header-script">
    <script type="text/javascript">
        function validateTag(name) {
            var result = true;
            var reg = /^\S{1,20}$/;
            if(name==""){
                result = false;
                layer.tips('标签名不能为空', '#tagName', {
                    tips: [1, '#FF0033'],
                    time: 3000
                });
            }
            else {
                if (!reg.test(name)) {
                    result = false;
                    layer.tips('请输入长度为1-20位非空白标签名', '#tagName', {
                        tips: [1, '#FF0033'],
                        time: 3000
                    });
                } else {
                    $(function () {
                        onload = $.ajax({
                            async: false,
                            cache:false,
                            type: "POST",
                            url: "tag/validateTag",
                            data:{name:name},
                            contentType: "application/x-www-form-urlencoded",
                            datatype: "json",
                            success: function (data) {
                                //服务端返回-1，代表该用户名已存在
                                if (data == "-1") {
                                    layer.tips('标签名重复', '#tagName', {
                                        tips: [1, '#FF0033'],
                                        time: 3000
                                    });
                                    result = false;
                                }
                            }
                        });
                    });
                }
            }
            return result;
        }

        function validate() {
            var result = true;
            if (validateTag($('input[name="tagName"]').val()) == false) {
                result = false;
            }
            return result;
        }
    </script>
</rapid:override>

<rapid:override name="frame-content">
    <div style="padding: 15px;">
    <blockquote class="layui-elem-quote">
        <span class="layui-breadcrumb" lay-separator="/">
              <a href="/user/login">首页</a>
              <a><cite>标签列表</cite></a>
        </span>
    </blockquote>
    <div class="layui-row">
        <div class="layui-col-md4">
            <form class="layui-form" method="post" onsubmit="return validate()" id="myForm" action="tag/updateTag">
                <input type="hidden" name="tagId" value="${tag.tagId}">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <strong>修改标签</strong>
                    </div>
                    <div class="layui-input-block">
                        名称 <span style="color: #FF5722; ">*</span>
                        <input type="text" name="tagName" id="tagName" placeholder="请输入标签名称" autocomplete="off" class="layui-input"
                               value="${tag.tagName}"   >
                    </div>
                    <br>
                    <div class="layui-input-block">
                        标签描述
                        <input type="text" name="tagDescription" placeholder="请输入标签描述" autocomplete="off"
                               value="${tag.tagDescription}" class="layui-input">
                    </div>
                    <br>
                    <div class="layui-input-block">
                        <input type="submit" class="layui-btn" lay-filter="formDemo" value="修改"  onclick="setMyText()"/>
                    </div>
                </div>
            </form>
            <blockquote class="layui-elem-quote layui-quote-nm">
                温馨提示：
                <ul>
                    <li>1、标签名必选，建议不要太长</li>
                    <li>2、标签名勿重复</li>
                </ul>
            </blockquote>
        </div>
</rapid:override>
<%@include file="../framework.jsp" %>
